package cn.shyouchi.wuguanjia.android.ui.home.security.thread.contact;

import android.content.Intent;
import android.view.View;

import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.shyouchi.wuguanjia.android.R;

/**
 * Created by Eenie on 2016/12/29 at 16:12
 * Email: 472279981@qq.com
 * Des:
 */

public class ContactAdapter extends BaseSectionQuickAdapter<ContactSection, BaseViewHolder> {
    public ContactAdapter(List<ContactSection> data) {
        super(R.layout.item_contact_list, R.layout.item_contact_header, data);
    }


    @Override
    protected void convertHead(BaseViewHolder holder, ContactSection header) {

        holder.setText(R.id.tv_contact_header, header.header);
    }

    @Override
    protected void convert(BaseViewHolder holder, final ContactSection contactSection) {
        holder.setText(R.id.tv_contact_name_name, contactSection.t.getName());
        holder.setText(R.id.tv_contact_name_hint, contactSection.t.getName().substring(0, 1));
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, ContactDetailActivity.class);
                intent.putExtra("contact", contactSection.t);
                mContext.startActivity(intent);
            }
        });
    }
}
